#ifndef MAP_H
#define MAP_H

#include "Cell.h"

class Map
{
public:
    Map();
    virtual ~Map();

	void Clear();
	void Resize(unsigned int newRowCount, unsigned int newColumnCount);

	unsigned int GetRowCount() const;
	unsigned int GetColumnCount() const;


	const Cell* GetCell(unsigned int x, unsigned int y) const;
	Cell* GetCell(unsigned int x, unsigned int y);
	const Cell* operator()(unsigned int x, unsigned int y) const;
	Cell* operator()(unsigned int x, unsigned int y);

	const Pixel& GetFloorPixel(unsigned int x, unsigned int y) const;
	const Pixel& GetCeilingPixel(unsigned int x, unsigned int y) const;

private:
	void CopyCellPointers(Cell** newcellmap, unsigned int newRowCount, unsigned int newColumnCount);
	void ClearCellPointers(Cell** newcellmap, unsigned int newRowCount, unsigned int newColumnCount);
	void InitializeCellPointers(Cell** newcellmap, unsigned int newRowCount, unsigned int newColumnCount);
	void CleanupCellPointers();


	unsigned int rowCount, columnCount;
	unsigned int unitSize;
	Cell** cellmap;

	static const unsigned int DEFAULT_ROWCOUNT = 10, DEFAULT_COLUMNCOUNT = 10;
	static const unsigned int DEFAULT_UNITSIZE = 64;
};

#endif // MAP_H
